package com.lemon.tuvi2015;

import org.json.JSONException;

import com.lemon.tuvi2015.object.XongdatObject;
import com.lemon.tuvi2015.util.JsonParser;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TableLayout.LayoutParams;
import android.widget.TextView;

public class XongdatTime extends Fragment{
	XongdatObject xongdatObject;
	public XongdatTime(String result) {
		try {
			xongdatObject=JsonParser.readxongdatngay(result).get(0);
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		TextView textView = new TextView(getActivity());
		LinearLayout.LayoutParams layoutParams=new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		layoutParams.setMargins(5, 5, 5, 5);
		textView.setLayoutParams(layoutParams);
		textView.setPadding(10, 5, 5, 5);
		textView.setTextColor(Color.BLACK);
		if (xongdatObject!=null) {
			String s="Ngày: "+xongdatObject.getdate()+"\nGiờ: "+xongdatObject.gettime();
			textView.setText(s);
		}
		return textView;
	}
}
